<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.google.appengine.api.datastore.KeyFactory" %>
<%@ include file="/common/cms/taglibs.jsp"%>
<%@include file="/common/cms/common-header.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
	$(function(){
		$("#add").click(function(){
			location.href = "${ctx}/channel/add";
		});
		
		$("#bulkDel").click(function(){
			var items = youboy.select();
			if(items && items.length > 0 && confirm("你确定要删除这些内容吗?")){
				$('input[name="_method"]').remove();
				$("#myForm").attr("action", "${ctx}/site/delete")
							.attr("method","post")
							.append('<input type="hidden" name="_method" value="DELETE" />')
							.submit();
				
				return false;
			}
			
			alert("请先选择要删除的内容");
			return false;
		});
		
		$(".del").each(function(){
			$this = $(this);
			var id = $this.attr("id");
			
			$(this).click(function(){
				if(confirm("你确定要删除这条记录吗?")){
					$.ajax({
						url : "${ctx}/channel/" + id + "/delete",
						type : "POST",
						data : {"_method":"DELETE"},
						success : function(){
							location.reload();
						},
						error : function(){
							alert("无法删除该数据！");
						}
					});
					
					return false;
				}
			});
		});
		
	});
</script>
</head>
<title>Channel Table List</title>
<body>
	<h1>Channel Table List</h1>

	Function : <a href="add">Add Channel</a>
	<hr />

	<h2>All Channels</h2>
	<table border="1">
		<thead>
			<tr>
				<td>id</td>
				<td>fatherId</td>
				<td>name</td>
				<td>path</td>
				<td>sort</td>
				<td>title</td>
				<td>tags</td>
				<td>hotKeyWord</td>
				<td>metaKeyWord</td>
				<td>metaTitle</td>
				<td>metaDescr</td>
				<td>anchorText</td>
				<td>attributes</td>
				<td>date</td>
			</tr>
		</thead>
		
		<c:forEach var="channel" items="${channels}">
			<tr>
				<td>${channel.id }</td>
				<td>${channel.fatherId }</td>
				<td>${channel.name }</td>
				<td>${channel.path }</td>
				<td>${channel.sort }</td>
				<td>${channel.title }</td>
				<td>${channel.tags }</td>
				<td>${channel.hotKeyWord }</td>
				<td>${channel.metaKeyWord }</td>
				<td>${channel.metaTitle }</td>
				<td>${channel.metaDescr }</td>
				<td>${channel.anchorText }</td>
				<td>${channel.attributes }</td>
				<td>${channel.date }</td>
				<td><a href="${ctx}/channel/update/${channel.id}">Update</a> 
		                   | <a class="del" href="javascript:;">Delete</a></td>
			</tr>
		</c:forEach>
         
        </tr>
     
	</table>

</body>
</html>